package web;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import util.web.ServletUtil;

import entity.CarShop;

public class RemoveList extends HttpServlet {

	
	private static final long serialVersionUID = 1L;

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		
		String bookid = request.getParameter("bookid");
		
		List<CarShop> list = (List<CarShop>) request.getSession().getAttribute("carshop");
		for (CarShop c : list) {
			if (c.getBook().getId().equals(bookid)) {
				list.remove(c);
				break;
			}
		}
		
		ServletUtil.setsessionAttri(request, "carshop", list);
		ServletUtil.sendRedirect(response, "showcar.jspx");
		
	}

}
